package com.example.rlw.mvpplugintest.prompt;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Toast;

import com.example.rlw.mvpplugintest.R;
import com.kingja.loadsir.callback.Callback;
import com.zyao89.view.zloading.ZLoadingDialog;
import com.zyao89.view.zloading.ZLoadingView;
import com.zyao89.view.zloading.Z_TYPE;


/**
 * 加载动画的回调
 */
public class LoadingCallback extends Callback {

    private ZLoadingDialog dialog;

    @Override
    protected int onCreateView() {
        return R.layout.layout_loading;
    }

    /*显示该加载页面布局的时候是否显示原来的布局是否展示*/
    @Override
    public boolean getSuccessVisible() {
        return true;
    }

    @Override
    public void onAttach(Context context, View view) {
        super.onAttach(context, view);
        if (dialog == null) {
            dialog = new ZLoadingDialog(context);
            dialog.setCanceledOnTouchOutside(false); //设置点击空白页面dialog不消失
            dialog.setLoadingBuilder(Z_TYPE.ROTATE_CIRCLE)//设置类型
                    .setLoadingColor(Color.WHITE)//颜色
                    .setHintText("Loading...")
                    .setHintTextSize(16) // 设置字体大小 dp
                    .setHintTextColor(Color.WHITE)  // 设置字体颜色
                    .setDurationTime(0.5) // 设置动画时间百分比 - 0.5倍
                    .setDialogBackgroundColor(Color.parseColor("#CC111111")); // 设置背景色，默认白色
        }
        dialog.show();
    }

    @Override
    protected boolean onReloadEvent(Context context, View view) {
        return true;
    }

    @Override
    public void onDetach() {
        super.onDetach();
        dialog.dismiss();
    }
}
